package com.zhong.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhong.blog.mapper.ReplyMapper;
import com.zhong.blog.pojo.Reply;
import com.zhong.blog.service.ReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReplyServiceImpl implements ReplyService {
    @Autowired
    ReplyMapper replyMapper;
    @Override
    public void reply(Reply reply) {
        int insert = replyMapper.insert(reply);
    }

    @Override
    public List<Reply> queryBycommentandblog(int commmentId, int blogid) {
        QueryWrapper<Reply> queryWrapper = new QueryWrapper<>();
        queryWrapper = queryWrapper.eq("blog_id",blogid);
        queryWrapper = queryWrapper.eq("comment_id",commmentId);

        queryWrapper.orderByAsc("create_time");

        List<Reply> replies = replyMapper.selectList(queryWrapper);
        return replies;
    }
}
